import { defineComponent } from 'vue'
import JsonPretty from 'vue-json-pretty'

export default defineComponent({
  props: {
    jsonString: String,
  },
  setup(props, ctx) {
    const parseJson = (jsonString) => {
      try {
        return JSON.parse(jsonString)
      } catch (e) {
        return null
      }
    }

    return () => <JsonPretty data={parseJson(props.jsonString)} style={{ height: '100%' }} />
  },
})
